#ifndef _CONFIGLIST_H_
#define _CONFIGLIST_H_

#include "struct.h"
/* A configuration is a production rule of the grammar together with
** a mark (dot) showing how much of that rule has been processed so far.
** Configurations also contain a follow-set which is a list of terminal
** symbols which are allowed to immediately follow the end of the rule.
** Every configuration is recorded as an instance of the following: */
enum cfgstatus {
  COMPLETE,
  INCOMPLETE
};

class Lemon;
class Config {
public:
  Config():rp(0),dot(0),fws(0),stp(0),status(COMPLETE),next(0){}
  Rule *rp;         /* The rule upon which the configuration is based */
  int dot;                 /* The parse point */
  char *fws;               /* Follow-set for this configuration only */

  /* A followset propagation link indicates that the contents of one
  ** configuration followset should be propagated to another whenever
  ** the first changes. */
  ConfigList fplp;      /* Follow-set forward propagation links */
  ConfigList bplp;      /* Follow-set backwards propagation links */

  State *stp;       /* Pointer to state which contains this */
  enum cfgstatus status;   /* used during followset and shift computations */
  Config *next;     /* Next configuration in the state */
};

Config *Configlist_add(Rule *, int);
Config *Configlist_addbasis(Rule *, int);
void Configlist_closure(Lemon *);
void Configlist_sort(void);
void Configlist_sortbasis(void);
ConfigList& Configlist_return(void);
ConfigList& Configlist_basis(void);
void Configlist_eat(const ConfigList&);
void Configlist_reset(void);

#endif // _CONFIGLIST_H_
